<template>
  <div class="shop-channel">
      <div class="container">
        <div class="model-title">商户渠道信息详情</div>
        <div v-loading="loading" class="list-box">
            <div class="filter-box">
              <el-row :gutter="10">
                <el-col :xs="24" :sm="8" >
                  <div class="grid-content ">
                    <span class="text-overflow">商户名:</span>
                    <el-input class="filter-input" clearable v-model="filters.merchantName" placeholder="商户名查询"></el-input>
                  </div>
                </el-col>
                <el-col :xs="24" :sm="8" >
                  <div class="grid-content ">
                    <span class="text-overflow">商户号:</span>
                    <el-input class="filter-input" clearable v-model="filters.merchantNo" placeholder="商户号查询"></el-input>
                  </div>
                </el-col>
                <el-col :xs="24" :sm="8" >
                  <div class="grid-content ">
                    <span class="text-overflow">绑定手机:</span>
                    <el-input class="filter-input" clearable v-model="filters.bindMobile" placeholder="绑定手机查询"></el-input>
                  </div>
                </el-col>
              </el-row>
              <div style="text-align:right;margin:20px" ><el-button @click="queryByStatus">查询</el-button></div>
            </div>
            <div class="channel-list">
               <table v-if="channel_list.length !== 0" border="0" cellspacing="0">
                    <thead>
                      <tr>
                        <th><div class="table-cell">商户号</div></th>
                        <th><div class="table-cell">商户名</div></th>
                        <th><div class="table-cell">绑定手机</div></th>
                        <th><div class="table-cell">状态</div></th>
                        <th><div class="table-cell">操作</div></th>
                      </tr>
                    </thead>
                    <tbody >
                      <tr v-for="(cell,index) in channel_list" :key="index">
                        <td><div class="table-cell" v-html="cell.merchantNo"></div></td>
                        <td><div class="table-cell" v-html="cell.merchantName"></div></td>
                        <td><div class="table-cell" v-html="cell.bindMobile"></div></td>
                        <td><div class="table-cell" v-html="cell.pwrStatus"></div></td>
                        <td><div class="table-cell" > <el-button @click="handleLookDetail(cell)" >查看详情</el-button> </div></td>
                      </tr>
                    </tbody>

                 </table>
                 <div class="no-data" v-else>
                    暂无数据
                 </div>
            </div>
               <div class="pages-control">
                  <el-pagination
                    @current-change="handleCurrentChange"
                    :current-page.sync="pages.currentPage"
                    :page-size="pages.page_size"
                    layout="prev, pager, next, jumper"
                    :total="pages.total">
                  </el-pagination>
              </div> 
        </div>
      </div>
  </div>
</template>

<script>
export default {
  name: "shop-channel",
  data() {
    return {
      loading:false,
      channel_list: [
        {
          bindMobile: "1350000000",
          pwrStatus: "0",
          merchantNo: "1539063688534",
          merchantName: "xxxx"
        }
      ],
      filters:{
        merchantNo:'' ,
        merchantName:'' ,
        bindMobile:''
      },
      pages: {
        total: 10,
        page_size: 20,
        currentPage: 1
      }
    };
  },
  components: {},
  created() {
    this.queryByStatus()
  },
  mounted() {},
  methods: {
    queryByStatus(){
      if(this.loading){
        return;
      }
      const token =sessionStorage.getItem('1');
      let url = `user/freeQtuick/queryMerchantFeeInfoList/${token}`;
      let params = `page=${this.pages.currentPage-1}&size=${this.pages.page_size}`;
      for(let key in this.filters){
        if(this.filters[key]!==null && this.filters[key]!==''){

          params+=`&${key}=${this.filters[key]}`

        }
      }
      this.loading = true;
      this.$Http.post(url,params).then(res=>{
        this.loading = false;
        if(res.data.resp_code === '000000'){
          this.channel_list = res.data.result.content || [];
          this.pages.total = res.data.result.totalElements || 0;
          if(res.data.result.content.length<=0){
              this.$notify.info({
              title: '消息',
              message: "暂无信息！"
              }); 
          }
        }else{
          this.$notify.info({
                    title: '消息',
                    message: res.data.resp_message
                });
        }
      }).catch(err=>{
        this.loading = false;
        this.$notify.error({
            title: '错误',
            message: '获取信息失败！'
        });
      })

    },
    handleCurrentChange(value) {
      this.queryByStatus()
    },
    handleLookDetail(cell) {
      this.$router.push({name:'channelShopDetail',params:{merchantNo:cell.merchantNo,channelProductCode:cell.channelProductCode}})
    }
  }
};
</script>
<style scoped>
.list-box {
  padding: 20px 10px;
}
.member-list{
  min-height: 300px;
  position: relative;
}
.pages-control{
  border-top: 1px solid #ededed;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.no-data{
  min-height: 300px;
  text-align: center;
  line-height: 200px
}
table{
    background-color: #FFF;
    width: 100%;
    font-size: 12px;
    min-width: 900px;
}
th{
    position: relative;
    word-wrap: normal;
    text-overflow: ellipsis;
    vertical-align: middle;
    border-bottom: 1px solid #ebeef5;
    
}
thead{
    padding: 8px 0;
    color: #909399;
}
tr{
    padding: 8px 0;
}
tr:hover{
    background-color: #F5F7FA;
}
td{
    border: none;
    border-bottom: 1px solid #ebeef5;
}
.table-cell{
    white-space: normal;
    word-break: break-all;
    line-height: 22px;
    padding: 10px 10px;
    text-align: center;
    min-width: 40px;
    box-sizing: border-box;
}

.filter-input,.filter-select{
  width: 160px;
  margin-right: 10px;
}

</style>